package com.sync.discruptor;

import com.lmax.disruptor.RingBuffer;
import com.sync.mutiParse.ReadManager;

/**
 * 生产者，生产longEvent事件
 * 
 * @author harry
 *
 */
public class LongEventProducer {
	private final RingBuffer<LongEvent> ringBuffer;

	public LongEventProducer(RingBuffer<LongEvent> ringBuffer) {
		this.ringBuffer = ringBuffer;
	}

	public void product() {
		long sequence = ringBuffer.next(); // Grab the next sequence
		try {
			LongEvent event = ringBuffer.get(sequence); // Get the entry in the
														// Disruptor
														// for the sequence
			ReadManager.readBlock(event.get()); // Fill with data
		} finally {
			ringBuffer.publish(sequence);
		}
	}
}